package pers.chy.chyappointmentplatform.Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pers.chy.chyappointmentplatform.Mapper.HisMapper.Ms_BrdaMapper;
import pers.chy.chyappointmentplatform.Mapper.HisMapper.T_LydjMapper;
import pers.chy.chyappointmentplatform.Model.Ms_BrdaDTO;
import pers.chy.chyappointmentplatform.Model.T_LydjExtDTO;
import pers.chy.chyappointmentplatform.Model.Yjyy_ZsxxExtDTO;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 来院登记服务类
 */
@Service
public class LydjService {

    @Autowired
    private T_LydjMapper t_lydjMapper;

    @Autowired
    private Ms_BrdaMapper ms_brdaMapper;

    /**
     * 登记来访者信息
     *
     * @return
     */
    public String doRecordVisitorInfo(Map params, String czrygh) {
        try {

            T_LydjExtDTO entity = new T_LydjExtDTO();
            entity.setBrxm(params.get("brxm")== null ? "" : params.get("brxm").toString());
            entity.setBrxb(params.get("brxb")== null ? "" : params.get("brxb").toString());
            entity.setBrnl(params.get("brnl")== null ? "" : params.get("brnl").toString());
            entity.setJtdz(params.get("jtdz")== null ? "" : params.get("jtdz").toString());
            entity.setLxdh(params.get("lxdh")== null ? "" : params.get("lxdh").toString());
            entity.setSfzh(params.get("sfzh")== null ? "" : params.get("sfzh").toString());
            entity.setJzkh(params.get("jzkh")== null ? "" : params.get("jzkh").toString());
            entity.setBzxx(params.get("bzxx")== null ? "" : params.get("bzxx").toString());
            entity.setDjsj(new Date());
            entity.setDjry(czrygh);
            entity.setYqbs(Integer.parseInt(params.get("yqbs").toString()));
            entity.setFrs(params.get("frs").toString());
            entity.setLjs(params.get("ljs").toString());
            entity.setJcs(params.get("jcs").toString());
            entity.setLymd(params.get("lymd").toString());

            t_lydjMapper.insert(entity);

            return null;
        } catch (Exception ex) {
            throw ex;
        }
    }


    /**
     * 获取病人档案信息
     *
     * @return
     */
    public Ms_BrdaDTO doGetBrxx(Map params) {
        try {

            Ms_BrdaDTO ret = ms_brdaMapper.selectByJzkh(params.get("jzkh").toString());

            return ret;
        } catch (Exception ex) {
            throw ex;
        }
    }

}
